package com.sebarmeli.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.sebarmeli.model.User;
public class LoginPage extends Page{
	User admin=new User();
	public LoginPage(PageManager pages)
	{
		super(pages);
	}
	@FindBy(id="username")
	private WebElement user_field;
	
	@FindBy(name="password")
	private WebElement password_field;
	
	@FindBy(name="submit")
	private WebElement submit_button;
	
	public LoginPage UsernameInput()
	{
		user_field.sendKeys(admin.getLogin());
		return this;	
	}
	
	public LoginPage PasswordInput()
	{
		password_field.sendKeys(admin.getPassword());
		return this;
	}
	
	public FilmsHomePage Submit()
	{
		
		submit_button.click();
		return pages.filmsHomePage;
	}
	
	public LoginPage ensurePageLoaded()
	{
		super.ensurePageLoaded();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.id("loginform")));
	    return this;
	}

}
